<include file="Public:header" />
<link rel="stylesheet" href="__PUBLIC__/Home/css/duobao.css" id="theme" />
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
<script src="__PUBLIC__/Home/js/form-validation.js"></script>
<div class='sep'></div>
<div class="autobox " style='margin-top:20px;'>
    <div class="left w215 ">
        <div class="user-panel">
            <div class="user-info">
                <dl>
                    <dt class='user-logo'>
                    <img src="https://www.a5.net/uc_server/images/noavatar_small.gif" onerror="this.onerror=null;this.src='https://www.a5.net/uc_server/images/noavatar_small.gif'"> <i></i>
                </dt>
                    <dd class='username'>
                        <a href="#">{$Think.session.user.username}</a>
                    </dd>
                    <!-- ￥ -->
                    <dd class="total"><i class='fa fa-rmb'></i> 交易额：</dd>
                    <dd class='total-money'>{$total1}元
                    </dd>
                </dl>
                <div class="dashedline"></div>
            </div>
            <ul class="deal-info">
                <li>
                    <a href="plugin.php?id=guarantee:guarantee&amp;item=status_4">
                        <div>交易中</div>
                        <div class='jiaoyi-count'>{$total2}</div>
                    </a>
                </li>
                <li style="border:none;">
                    <a href="plugin.php?id=guarantee:guarantee&amp;item=status_6">
                        <div>已结束</div>
                        <div class='jiaoyi-count'>{$total3}</div>
                    </a>
                </li>
            </ul>

            <div class="post-deal">
                <a class="btn" href="{:U('duobao/add')}" target="_blank">
                    <i class=' fa fa-plus-square-o'></i> 发起交易
                </a>
            </div>
            <div class="tips">
                <i class='fa fa-check-circle-o'></i> 安全 便捷 高效
            </div>
        </div>
        <div class="flow">
            <section class="con-side">
                <header>
                    <h2 class="f5">
                        <i class='fa fa-list-ol'></i> 担保交易流程
                    </h2>
                </header>
                <article class="flow-content">

                    <dl>
                        <dt>
                        <i class='step1' ></i>
                        </dt>
                        <dd>
                            <strong>发起交易</strong>
                            <span>只需一方发起即可</span>
                        </dd>
                    </dl>
                    <dl>
                        <dt>
                        <i class='step2'></i>
                        </dt>
                        <dd>
                            <strong>对方接受</strong>
                            <span>点击按钮 接受交易</span>
                        </dd>
                    </dl>
                    <dl>
                        <dt>
                        <i class='step3'></i>
                        </dt>
                        <dd>
                            <strong>买家付款</strong>
                            <span> 双方开始交易</span>
                        </dd>
                    </dl>
                    <dl class="p0">
                        <dt>
                        <i class='step4'></i>
                        </dt>
                        <dd>
                            <strong>交易结束</strong>
                            <span>每天10点和17点统一支付</span>
                        </dd>
                    </dl>
                </article>
            </section>
        </div>
    </div>
    <div class="left right-content">
        <div class="con-right-post">
            <div class="hd">
                <h2 class="left">
                    <i class='fa fa-info fa-fw'></i> 交易详细信息
                </h2>
            </div>
            <div class="bd">
                <form method="post" autocomplete="off" id="signupForm">
                    <div id="ct" class="duobao-form">
                        <div class="bm bw0 cl">

                            <div id="postbox">
                                <div class="specialpost s_clear">
                                    <dl>
                                        <dt>我的手机号：</dt>
                                        <dd>
                                            {$data.phone}
                                        </dd>
                                    </dl>
                                    <div class="clear"></div>
                                    <div class="blank10"></div>
                                    <div class="blank5"></div>
                                    <dl><dt>买卖关系：</dt>
                                        <dd>
                                            <eq name='data.role' value='1'>
                                                我是买家
                                            </eq>
                                            <eq name='data.role' value='2'>
                                                我是卖家
                                            </eq>

                                        </dd>
                                        <div class="clear"></div>
                                    </dl>
                                    <div class="clear"></div>
                                    <div class="blank10"></div>
                                    <div class="blank5"></div>
                                    <dl><dt>对方用户名：</dt>
                                        <dd>
                                            {$data.other_side_username}
                                        </dd>
                                    </dl>
                                    <div class="clear"></div>
                                    <div class="blank10"></div>
                                    <div class="blank5"></div>
                                    <dl><dt>购买货币种类：</dt>
                                        <dd>
                                            {$data.coinName}
                                        </dd>
                                    </dl>

                                    <div class="clear"></div>
                                    <div class="blank10"></div>
                                    <div class="blank5"></div>
                                    <dl><dt>购买货币价格：</dt>
                                        <dd>
                                            {$data.coin_price}元
                                        </dd>
                                    </dl>

                                    <div class="clear"></div>
                                    <div class="blank10"></div>
                                    <div class="blank5"></div>
                                    <dl><dt>购买货币数量：</dt>
                                        <dd>
                                            {$data.coin_count}
                                        </dd>
                                    </dl>

                                    <div class="clear"></div>
                                    <div class="blank10"></div>
                                    <div class="blank5"></div>

                                    <if condition="$data.user_id == userid()">
                                        <if condition="$data.role == 1">

                                            <dl><dt>应付总价：</dt>
                                                <dd>
                                                    <div class="total-c">
                                                        <p>
                                                            <span id='buyer-title'>
                                                                            
                                                                    </span>
                                                            <em id="order_amount">{$data.coin_total}元</em>
                                                        </p>
                                                    </div>
                                                </dd>
                                            </dl>
                                            <else />
                                            <dl><dt>应得总价：</dt>
                                                <dd>
                                                    <div class="total-c">
                                                        <p>
                                                            <span id='buyer-title'>
                                                                        
                                                                </span>
                                                            <em id="order_amount">{$data.other_coin_total}元</em>
                                                        </p>
                                                    </div>
                                                </dd>
                                            </dl>
                                        </if>

                                        <else />
                                        <if condition="$data.role == 1">

                                            <dl><dt>应得总价：</dt>
                                                <dd>
                                                    <div class="total-c">
                                                        <p>
                                                            <span id='buyer-title'>
                                                                        
                                                                </span>
                                                            <em id="order_amount">{$data.other_coin_total}元</em>

                                                        </p>
                                                    </div>
                                                </dd>
                                            </dl>
                                            <else />
                                            <dl><dt>应付总价：</dt>
                                                <dd>
                                                    <div class="total-c">
                                                        <p>
                                                            <span id='buyer-title'>
                                                                        
                                                                </span>
                                                            <em id="order_amount">{$data.coin_total}元</em>
                                                        </p>
                                                    </div>
                                                </dd>
                                            </dl>
                                        </if>
                                    </if>
                                    <div id='real-name-panel'>
                                        <div class="clear"></div>
                                        <div class="blank10"></div>
                                        <div class="blank5"></div>
                                        <dl id="buyuserName"><dt>真实姓名：</dt>
                                            <dd>{$data.real_name}
                                            </dd>
                                        </dl>
                                    </div>
                                    <div class="clear"></div>
                                    <div class="blank10"></div>
                                    <div class="blank5"></div>

                                    <div class="clear"></div>
                                    <div class="blank10"></div>
                                    <div class="blank5"></div>
                                    <dl id="businessMark"><dt>交易备注：</dt>
                                        <dd>
                                            {$data.business_mark}
                                        </dd>
                                    </dl>
                                    <if condition="$data.user_id != userid() and $data.status == 1">

                                        <div class="clear"></div>
                                        <div class="blank10"></div>
                                        <div class="blank5"></div>
                                        <div style="margin:0 auto;width:400px;">
                                            <input type="button" style='float:left;' class="save-deal-btn" id='save-btn-1' value="同意交易">
                                            <input type="button" style='float:right;background:grey;  border:none;  box-shadow: 0 12px 0 grey inset;' class="save-deal-btn" id='save-btn-2' value="拒绝交易"></div>
                                    </if>

                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="__PUBLIC__/kindeditor/kindeditor-min.js"></script>
<script src="__PUBLIC__/Home/js/duobao.js"></script>
<script>
    $("#save-btn-1").click(function() {
        $.post("{:U('duobao/accept')}", {
            id: "{$data.id}"
        }, function(result) {
            if (result.result) {
                alert("交易成功");
                window.location.href = 'index';
            } else {
                alert(result.msg);
            }
        }, "json");
    });
    $("#save-btn-2").click(function() {
        $.post("{:U('duobao/refuse')}", {
            id: "{$data.id}"
        }, function(result) {
            if (result) {
                alert("拒绝交易成功");
                window.location.href = 'index';
            } else {
                alert("拒绝交易失败");
            }
        }, "json");
    });
</script>
<include file="Public:footer" />